package ems.dev.easycode.util;

import cn.hutool.core.util.StrUtil;
import com.google.common.base.CaseFormat;

/**
 * @author 狠穿
 * @version 1.0.0
 * @date 2023/6/23
 * @function
 */
public class FormatUtil {
    public static String tableNameToDomainName(String tableName){
        //配置类表名和页面号的映射，则采用映射后的页面号
        String pageNo = MappingUtil.getPageNo(tableName);
        if(StrUtil.isNotBlank(pageNo)){
            return pageNo;
        }
        //否则，对下划线格式的表名称转换成驼峰格式
        String tablePrefix = PropertiesUtil.getProValueStr(Constant.EASY_CODE_PROPERTIES_FILE_NAME, Constant.EASYCODE_DB_TABLE_PREFIX);
        String tableNameWithoutPrefix = StrUtil.replace(tableName, tablePrefix, StrUtil.EMPTY);
        return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL,tableNameWithoutPrefix);
    }

    public static String dbColumnToLowerCamelCase(String column){
        return CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,column);
    }

    public static void main(String[] args) {
        System.out.println(tableNameToDomainName("T_HA_GAS_RMPY"));
    }
}
